package com.zez.controller;

import com.zez.util.PageResult;
import com.zez.entity.Student;
import com.zez.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student")
@CrossOrigin            // 解决跨域问题
public class StudentController {

    @Autowired
    private StudentService studentService;

    //1. 获取学生列表
    @GetMapping("/list")
    public List<Student> list(){
        return studentService.findAll();
    }

    //2. 分页查询学生信息
    @GetMapping("/findByPage")
    public PageResult<Student> findByPage(@RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize){
        return studentService.findByPage(page, pageSize);
    }
}
